package com.hs.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.Publicity;
import com.hs.sfzy.mapper.PublicityMapper;
import com.hs.sfzy.service.PublicityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName PublicityServiceImpl
 * @Description TODO
 * @Author msj
 * @Date 2024年10月23日 18:43
 * @Version 1.0
 */
@Service
public class PublicityServiceImpl implements PublicityService {
    @Autowired
    private PublicityMapper publicityMapper;

    @Override
    public int add(Publicity publicity) {
        return publicityMapper.insert(publicity);
    }

    @Override
    public int edit(Publicity publicity) {
        return publicityMapper.update(publicity);
    }

    @Override
    public int remove(Long id) {
        return publicityMapper.delete(id);
    }

    @Override
    public List<Publicity> findAll(Publicity publicity) {
        return publicityMapper.select(publicity);
    }

    @Override
    public Publicity findById(Long id) {
        return publicityMapper.selectById(id);
    }

    @Override
    public PageInfo<Publicity> findByPage(Integer pageNum, Integer pageSize, Publicity publicity) {
        PageHelper.startPage(pageNum,pageSize);
        List<Publicity> list = publicityMapper.select(publicity);
        PageInfo<Publicity> pageInfo = new PageInfo<Publicity>(list);
        return pageInfo;
    }
}
